package com.xdtech.trans.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.sql.Timestamp;

import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.Role;
import com.xdtech.sys.model.UserGroup;
import com.xdtech.sys.vo.UserItem;
import com.xdtech.trans.model.Person;
import com.xdtech.trans.model.TransWebSite;

import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2015-05-28 00:20:05
 * @since 1.0
 * @see
 */
public class PersonItem extends UserItem implements Serializable{
	private static final long serialVersionUID = 1L;
	private Long id;
	@GridColumn(title="姓名",width=100)
	private String name;
	@GridColumn(title="登录名",width=100)
	private String loginName;
//	@GridColumn(title="所属机构",width=100)
	private String userGroup;
	@GridColumn(title="状态",formatter={"0=<span style=\"color:red;\">禁用</span>","1=<span style=\"color:green;\">在用</span>"})
	private String status;
//	@GridColumn(title="权限角色",width=100)
	private String role;
	@GridColumn(title="员工类型",dictionaryCode="PERSON_TYPE",width=100)
	private String personType;
	@GridColumn(title="职位",width=100)
	private String personPosition;
	@GridColumn(title="任职状态",dictionaryCode="POSITION_STATUS",width=100)
	private String positionStatus;
	@GridColumn(title="性别",dictionaryCode="SEX",width=100)
	private String sex;
	@GridColumn(title="身份证号",width=100)
	private String idCard;
	@GridColumn(title="身份证地址",width=100)
	private String cardAddress;
	@GridColumn(title="家庭住址",width=100)
	private String homeAddress;
	@GridColumn(title="出生日期",width=100)
	private String birthday;
	@GridColumn(title="婚姻状况",dictionaryCode="MARITAL_STATUS",width=100)
	private String maritalStatus;
	@GridColumn(title="文化程度",dictionaryCode="EDUCATION_LEVEL",width=100)
	private String educationLevel;
	@GridColumn(title="入职时间",width=100)
	private String hireDate;
	@GridColumn(title="离职时间",width=100)
	private String departureDate;
	@GridColumn(title="联系人",width=100)
	private String contract;
	@GridColumn(title="手机",width=100)
	private String mobilePhone;
	@GridColumn(title="电话",width=100)
	private String telephone;
	@GridColumn(title="国家/省市",width=100)
	private String stateProvince;
	@GridColumn(title="联系地址",width=100)
	private String contractAddress;
	@GridColumn(title="邮编",width=100)
	private String postCode;
	@GridColumn(title="邮箱",width=100)
	private String email;
	@GridColumn(title="传真",width=100)
	private String fax;
	@GridColumn(title="QQ",width=100)
	private String qq;
	
	private String websiteId;
	
	private String websiteName;
	
	private String websiteIds;
	

	public void setId(Long id) {
		this.id = id;
		addQuerys("id", id);
	}
	public Long getId() {
		return id;
	}
	
	public void setName(String name) {
		this.name = name;
		addQuerys("name", name);
	}
	public String getName() {
		return name;
	}
	
	public void setLoginName(String loginName) {
		this.loginName = loginName;
		addQuerys("loginName", loginName);
	}
	public String getLoginName() {
		return loginName;
	}
	
	public void setUserGroup(String userGroup) {
		this.userGroup = userGroup;
		addQuerys("userGroup", userGroup);
	}
	public String getUserGroup() {
		return userGroup;
	}
	
	public void setStatus(String status) {
		this.status = status;
		addQuerys("status", status);
	}
	public String getStatus() {
		return status;
	}
	
	public void setRole(String role) {
		this.role = role;
		addQuerys("role", role);
	}
	public String getRole() {
		return role;
	}
	
	public void setPersonType(String personType) {
		this.personType = personType;
		addQuerys("personType", personType);
	}
	public String getPersonType() {
		return personType;
	}
	
	public void setPersonPosition(String personPosition) {
		this.personPosition = personPosition;
		addQuerys("personPosition", personPosition);
	}
	public String getPersonPosition() {
		return personPosition;
	}
	
	public void setIdCard(String idCard) {
		this.idCard = idCard;
		addQuerys("idCard", idCard);
	}
	public String getIdCard() {
		return idCard;
	}
	
	public void setCardAddress(String cardAddress) {
		this.cardAddress = cardAddress;
		addQuerys("cardAddress", cardAddress);
	}
	public String getCardAddress() {
		return cardAddress;
	}
	
	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
		addQuerys("homeAddress", homeAddress);
	}
	public String getHomeAddress() {
		return homeAddress;
	}
	
	public void setBirthday(String birthday) {
		this.birthday = birthday;
		addQuerys("birthday", birthday);
	}
	public String getBirthday() {
		return birthday;
	}
	
	public void setMaritalStatus(String maritalStatus) {
		this.maritalStatus = maritalStatus;
		addQuerys("maritalStatus", maritalStatus);
	}
	public String getMaritalStatus() {
		return maritalStatus;
	}
	
	public void setEducationLevel(String educationLevel) {
		this.educationLevel = educationLevel;
		addQuerys("educationLevel", educationLevel);
	}
	public String getEducationLevel() {
		return educationLevel;
	}
	
	public void setHireDate(String hireDate) {
		this.hireDate = hireDate;
		addQuerys("hireDate", hireDate);
	}
	public String getHireDate() {
		return hireDate;
	}
	
	public void setDepartureDate(String departureDate) {
		this.departureDate = departureDate;
		addQuerys("departureDate", departureDate);
	}
	public String getDepartureDate() {
		return departureDate;
	}
	
	public void setContract(String contract) {
		this.contract = contract;
		addQuerys("contract", contract);
	}
	public String getContract() {
		return contract;
	}
	
	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
		addQuerys("mobilePhone", mobilePhone);
	}
	public String getMobilePhone() {
		return mobilePhone;
	}
	
	public void setTelephone(String telephone) {
		this.telephone = telephone;
		addQuerys("telephone", telephone);
	}
	public String getTelephone() {
		return telephone;
	}
	
	public void setStateProvince(String stateProvince) {
		this.stateProvince = stateProvince;
		addQuerys("stateProvince", stateProvince);
	}
	public String getStateProvince() {
		return stateProvince;
	}
	
	public void setContractAddress(String contractAddress) {
		this.contractAddress = contractAddress;
		addQuerys("contractAddress", contractAddress);
	}
	public String getContractAddress() {
		return contractAddress;
	}
	
	public void setPostCode(String postCode) {
		this.postCode = postCode;
		addQuerys("postCode", postCode);
	}
	public String getPostCode() {
		return postCode;
	}
	
	public void setEmail(String email) {
		this.email = email;
		addQuerys("email", email);
	}
	public String getEmail() {
		return email;
	}
	
	public void setFax(String fax) {
		this.fax = fax;
		addQuerys("fax", fax);
	}
	public String getFax() {
		return fax;
	}
	
	public void setQq(String qq) {
		this.qq = qq;
		addQuerys("qq", qq);
	}
	public String getQq() {
		return qq;
	}
	
	public String getSex()
	{
		return sex;
	}
	public void setSex(String sex)
	{
		this.sex = sex;
		addQuerys("sex", sex);
	}
	public String getPositionStatus() {
		return positionStatus;
	}
	public void setPositionStatus(String positionStatus) {
		this.positionStatus = positionStatus;
		addQuerys("positionStatus", positionStatus);
	}
	public String getWebsiteId() {
		return websiteId;
	}
	public void setWebsiteId(String websiteId) {
		this.websiteId = websiteId;
		addQuerys("websiteId", websiteId);
	}
	public String getWebsiteName() {
		return websiteName;
	}
	public void setWebsiteName(String websiteName) {
		this.websiteName = websiteName;
	}
	public String getWebsiteIds() {
		return websiteIds;
	}
	public void setWebsiteIds(String websiteIds) {
		this.websiteIds = websiteIds;
		addQuerys("websiteIds", websiteIds);
	}
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static PersonItem createItem(Person person) {
		if (null == person)
		{
			return null;
		}
		PersonItem personItem = new PersonItem();
		BeanUtils.copyProperties(personItem, person);
		//自定义属性设置填充
		List<UserGroup> groups = person.getUserGroups();
		if (null != groups)
		{
			personItem.setUserGroup("");
			for (UserGroup userGroup : groups)
			{
				personItem.setUserGroup(personItem.getUserGroup()+userGroup.getId().toString()+",");
			}
		}
		List<Role> roles = person.getRoles();
		if (null != roles)
		{
			personItem.setRole("");
			for (Role role : roles)
			{
				personItem.setRole(personItem.getRole()+role.getId().toString()+",");
			}
		}
		TransWebSite transWebSite = person.getWebSite();
		if (transWebSite!=null) {
			personItem.setWebsiteId(transWebSite.getId().toString());
			personItem.setWebsiteName(transWebSite.getName());
		}
		return personItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<PersonItem> createItems(List<Person> persons) {
		List<PersonItem> personItems = new ArrayList<PersonItem>();
		for (Person person : persons) {
			personItems.add(createItem(person));
		}
		return personItems;
	}
}
